package com.cloudcc.boot.entity.sap;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.yangzg.cloudcc.openapi.entity.CloudCCObject;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
public class CrmOrderDto extends CloudCCObject {

    public static final String OBJECT_API_NAME = "cloudccorder";

    @JsonIgnore
    @JsonProperty("CCObjectAPI")
    private String objectApi = OBJECT_API_NAME;

    private String orderType;//销售订单类型-订单类型名称

    private String salesOrg;//销售组织-销售组织名称

    private String salesChannel;//分销渠道-分销渠道名称

    private String productGroup;//产品组-产品组名称

    private String soldAccountSapCode;//售达方-客户代码

    private String shipAccountSapCode;//运达方-客户代码

    private String salesContractNumber;//CRM销售合同编号

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date salesContractSignDate;//CRM销售合同签约日期

    private String paymentTermsCode;//付款条件代码

    private String paymentRatio;//收款比率-收货款

    private String acceptanceRatio;//收款比率-验收款

    private String warrantyRatio;//收款比率-质保金

    private String sapOrderNumber;//SAP销售订单编号

    private String pushedSapStatus;//SAP推送状态

    private String sapRtnMsg;//SAP返回信息

    private List<CrmOrderItemDto> items;

    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class CrmOrderItemDto extends CloudCCObject {

        public static final String OBJECT_API_NAME = "orderItem";

        @JsonIgnore
        @JsonProperty("CCObjectAPI")
        private String objectApi = OBJECT_API_NAME;

        @JsonAlias("orderid")
        @JsonProperty("orderid")
        private String orderId;

        @JsonAlias("materialccname")
        private String materialCode;//物料-物料代码

        @JsonAlias("salesQuantity")
        @JsonProperty("salesQuantity")
        private BigDecimal salesQuantity;//订单数量

        private String unit;//计量单位

        @JsonAlias("unitPrice")
        @JsonProperty("unitPrice")
        private BigDecimal unitPrice;//订单行单价

        private BigDecimal amount;//订单行（含税）总金额

        private String wbsCode;//WBS元素-WBS元素代码

        @JsonAlias("sapShippedQuantity")
        @JsonProperty("sapShippedQuantity")
        private int sapShippedQuantity;//SAP已发货数量

    }

}
